<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
	<head>
		<th:block th:include="include :: header('修改产品信息')" />
	</head>
	<body class="white-bg">
		<div class="row">
			<div class="wrapper wrapper-content animated fadeInRight ibox-content">
				<form class="form-horizontal m" id="form-pro-edit" th:object="${pro}">
					<input id="pid" name="pid" type="hidden" th:field="*{pid}"/>
					<input id="productPic.picId" name="productPic.picId" type="hidden" th:field="*{productPic.picId}"/>
					<div class="form-group">
						<label class="col-sm-3 control-label ">产品名称：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="pname" id="pname" th:field="*{pname}" required>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label ">产品类型：</label>
						<div class="col-sm-8">
							<select name="productClass.classId" th:with="proClass=${@proProp.getProductClass()}" th:field="*{productClass.classId}" >
								<option value="">---请选择产品类型---</option>
								<option th:each="c : ${proClass}" th:text="${c.className}" th:value="${c.classId}"></option>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label ">产品系列：</label>
						<div class="col-sm-8">
							<select name="productSeries.seriesId" th:with="proSeries=${@proProp.getProductSeries()}" th:field="*{productSeries.seriesId}" >
								<option value="">---请选择产品系列---</option>
								<option th:each="ps : ${proSeries}" th:text="${ps.seriesName}" th:value="${ps.seriesId}" ></option>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label ">产品风格：</label>
						<div class="col-sm-8">
							<select name="productStyle.styleId" th:with="proStyle=${@proProp.getProductStyle()}" th:field="*{productStyle.styleId}" >
								<option value="">---请选择产品风格---</option>
								<option th:each="ps : ${proStyle}" th:text="${ps.styleName}" th:value="${ps.styleId}"></option>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label ">产品规格：</label>
						<div class="col-sm-8">
							<select name="productSpec.specId" th:with="proSpec=${@proProp.getProductSpec()}" th:field="*{productSpec.specId}" >
								<option value="">---请选择产品规格---</option>
								<option th:each="ps : ${proSpec}" th:text="${ps.specName}" th:value="${ps.specId}"></option>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label ">产品材质：</label>
						<div class="col-sm-8">
							<select name="productMaterial.materialId" th:with="proMaterial=${@proProp.getProductMaterial()}" th:field="*{productMaterial.materialId}" >
								<option value="">---请选择产品材质---</option>
								<option th:each="m : ${proMaterial}" th:text="${m.materialName}" th:value="${m.materialId}"></option>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label ">产品产地：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="location" id="location" th:field="*{location}" required>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label ">产品价格：</label>
						<div class="col-sm-8">
							<input class="form-control" type="text" name="price" id="price" th:field="*{price}" required>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">进口在途：</label>
						<div class="col-sm-8">
							<select name="imp" th:with="type=${@dict.getType('sys_yes_no')}" th:field="*{imp}">
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">产品备注：</label>
						<div class="col-sm-8">
							<textarea id="pdesc" name="pdesc" class="form-control">[[*{pdesc}]]</textarea>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">产品展示：</label>
						<img th:src="${pro.productPic.picUrl}" alt="${pro.productPic.picName}">
						<div>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</div>
					</div>
					<!--直接强行下拉框展示？？？-->
				</form>
			</div>
		</div>
		<th:block th:include="include :: footer" />
		<script type="text/javascript">
			var prefix = ctx + "product/menu";

			$("#form-pro-edit").validate({
				onkeyup: false,
				rules:{
					pname:{
						remote: {
							url: ctx + "product/menu/checkPnameUnique",
							type: "post",
							dataType: "json",
							data: {
								"pname" : function() {
									return $.common.trim($("#pname").val());
								}
							},
							dataFilter: function(data, type) {
								return $.validate.unique(data);
							}
						}
					},
				},
				messages: {
					"pname": {
						remote: "产品名称已经存在"
					},
				},
				focusCleanup: true
			});

			function submitHandler() {
				if ($.validate.form()) {
					$.operate.save(prefix + "/edit", $('#form-pro-edit').serialize());
				}
			}
		</script>
	</body>
</html>
